﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;

using HsTec.Mobile.Green.Util;

namespace HsTec.Mobile.Green.BLL
{
    public class DeptPersManager
    {
        public int delPersonInfo(string oid,string pid)
        {
            SQLHelper.myconn.Open();
            SqlCommand command = SQLHelper.myconn.CreateCommand();
            SqlTransaction transaction;
            transaction = SQLHelper.myconn.BeginTransaction();
            command.Connection = SQLHelper.myconn;
            command.Transaction = transaction;
            try
            {
                //删除人员组织表中的人员和组织关系
                command.CommandText = "delete from Sys_DeptPers_Info where persid='" + pid + "'";
                command.ExecuteNonQuery();
                command.CommandText = "delete from sys_pers_info where id='" + pid + "'";
                command.ExecuteNonQuery();
                transaction.Commit();
                return 1;
            }
            catch
            {
                transaction.Rollback();
                return 0;
            }
            finally
            {
                transaction.Dispose();
                SQLHelper.myconn.Close();
            }
        }
    }
}
